﻿using System.Windows;
using Autofac;
using Jacobi.Vst.Core.Host;
using Play.AudioEngine;
using Play.Messaging;
using Play.Shell.ViewModels;
using Play.Shell.Views;
using Play.TrackManagement;
using Play.VstPluginManagement;

namespace Play
{
	class ContainerConfiguration
	{
		public ContainerConfiguration()
		{
			var builder = new ContainerBuilder();
			builder.RegisterModule(new MessageInterceptionModule());

			builder.RegisterType<AppSettings>().SingleInstance();
			builder.RegisterType<MainWindow>().AsSelf().As<Window>().SingleInstance();
			
			builder.RegisterType<PortAudioVstPlayback>().SingleInstance();
			builder.RegisterType<AudioRack>().SingleInstance();
			builder.RegisterType<Channel>().InstancePerDependency();

			builder.RegisterType<VstHostCommandStub>().As<IVstHostCommandStub>().SingleInstance();
			builder.RegisterType<VstPluginInfo>().InstancePerDependency();
			builder.RegisterType<VstPluginCatalog>().SingleInstance();
			builder.RegisterType<VstPluginFactory>().InstancePerDependency();

			builder.RegisterType<TrackSession>().SingleInstance();
			builder.RegisterType<TrackFactory>().InstancePerDependency();
			builder.RegisterType<Track>().InstancePerDependency();

			builder.RegisterType<MainViewModel>().SingleInstance();
			builder.RegisterType<SelectInstrumentViewModel>().InstancePerDependency();
			builder.RegisterType<TrackViewModel>().InstancePerDependency();

			Container = builder.Build();
		}

		public IContainer Container { get; private set; }
	}
}
